bug #783704, Check db NULL to avoid segfault if babl not initiated,
authorGuiu Rocafort <neandertalspeople@gmail.com>
Tue, 13 Jun 2017 07:21:29 +0000 (09:21 +0200)
committerØyvind Kolås <pippin@gimp.org>
Tue, 13 Jun 2017 07:26:11 +0000 (09:26 +0200)
babl/babl-internal.h

index 228faa5ab4cd1b889e2ba6136683b7a195f7c320..42262d6b0b3ff0f1b51c088f50895271fec8651e 100644 (file)
@@ -265,14 +265,22 @@ BABL_CLASS_MINIMAL_IMPLEMENT(klass)                           \
 const Babl *                                                  \
 babl_##klass (const char *name)                               \
 {                                                             \
-  Babl *babl;                                                 \
+  Babl *babl = NULL;                                          \
                                                               \
   if (babl_hmpf_on_name_lookups)                              \
     {                                                         \
       babl_log ("%s(\"%s\"): hmpf!", G_STRFUNC, name);        \
     }                                                         \
-  babl = babl_db_exist_by_name (db, name);                    \
                                                               \
+  if( db != NULL )                                            \
+   {                                                          \
+     babl = babl_db_exist_by_name (db, name);                \
+   }                                                          \
+ else{                                                        \
+   babl_fatal("You must call babl_init() first");             \
+ }                                                           \
+                                                              \
+                                                             \
   if (!babl)                                                  \
     {                                                         \
       babl_fatal ("%s(\"%s\"): not found", G_STRFUNC, name);  \